package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TextClock;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
    Button calu;
    EditText w,h;
    TextView temp;
    CheckBox man,woman;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        calu=findViewById(R.id.calculate);
        w=findViewById(R.id.weight);
        h=findViewById(R.id.height);
        temp=findViewById(R.id.bim);
        man=findViewById(R.id.man);
        woman=findViewById(R.id.woman);
        calu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                double weight=Double.parseDouble(w.getText().toString()),height=Double.parseDouble(h.getText().toString());
                double bim=weight/height/height;
                if(man.isChecked())
                {
                    if(bim>40){
                        temp.setText("某某某男士，您过度肥胖");

                    }
                        else if(bim>35)
                    {
                        temp.setText("某某某男士，您中度肥胖");
                    }
                    else if(bim>30)
                    {
                        temp.setText("某某某男士，您轻度肥胖");
                    }
                            else if(bim>25)
                    {
                        temp.setText("某某某男士，您超重了");
                    }
                                else if(bim>18)
                    {
                        temp.setText("某某某男士，您体重正常");
                    }
                                else{
                        temp.setText("某某某男士，您太瘦了");
                    }
                }
                else if(woman.isChecked())
                {
                    if(bim>40){
                        temp.setText("某某某女士，您过度肥胖");

                    }
                    else if(bim>35)
                    {
                        temp.setText("某某某女士，您中度肥胖");
                    }
                    else if(bim>30)
                    {
                        temp.setText("某某某女士，您轻度肥胖");
                    }
                    else if(bim>25)
                    {
                        temp.setText("某某某女士，您超重了");
                    }
                    else if(bim>18)
                    {
                        temp.setText("某某某女士，您体重正常");
                    }
                    else{
                        temp.setText("某某某女士，您太瘦了");
                    }
                }
            }
        });
    }
}